package com.work.cos.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.work.cos.domain.entity.VerCodeLogEntity;
import com.work.cos.mapper.base.IVerCodeLogMapper;
import com.work.cos.service.interfc.IVerCodeLogService;
import com.work.cos.util.ConfigInfo;
import com.work.cos.util.DateUtil;

@Service
public class VerCodeLogServiceImpl implements IVerCodeLogService{

	@Autowired
	private IVerCodeLogMapper verCodeLogMapper;
	
	String startTime = DateUtil.getDateString(new Date()) + ConfigInfo.START_TIME;
	
	String endTime = DateUtil.getDateString(new Date())+ ConfigInfo.END_TIME;

	@Override
	public boolean addVerCodeLog(VerCodeLogEntity verCodeLogInfo) {
		return this.verCodeLogMapper.save(verCodeLogInfo) > 0;
	}

	@Override
	public String getVerCodeNow(Long phone) {
		return this.verCodeLogMapper.getVerCodeNow(phone, startTime, endTime);
	}

	@Override
	public int getVerCodeCountByMobile(String phone) {
		return this.verCodeLogMapper.getVerCodeCountByMobile(phone, startTime, endTime);
	}

	@Override
	public int getVerCode(String phone, String code) {
		return this.verCodeLogMapper.getVerCode(phone, code);
	}
	
	
}
